<!DOCTYPE html>
<html>
<head>
    <title>快速API测试</title>
    <meta charset="utf-8">
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; }
        button { margin: 10px; padding: 10px; }
        #result { margin-top: 20px; padding: 10px; border: 1px solid #ccc; }
    </style>
</head>
<body>
    <h1>快速API测试</h1>
    
    <button onclick="testProductAPI()">测试商品API</button>
    <button onclick="testInitData()">初始化数据</button>
    <button onclick="testDataStats()">数据统计</button>
    
    <div id="result"></div>

    <script>
        function log(message) {
            const result = document.getElementById('result');
            result.innerHTML += '<p>' + new Date().toLocaleTimeString() + ': ' + message + '</p>';
            result.scrollTop = result.scrollHeight;
        }

        async function testProductAPI() {
            try {
                log('测试商品API...');
                const response = await fetch('https://localhost:7001/api/Product/get-products');
                const data = await response.json();
                log('商品API响应: ' + JSON.stringify(data, null, 2));
            } catch (error) {
                log('商品API错误: ' + error.message);
            }
        }

        async function testInitData() {
            try {
                log('初始化数据...');
                const response = await fetch('https://localhost:7002/api/DataInit/init-test-data', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    }
                });
                const data = await response.json();
                log('初始化响应: ' + JSON.stringify(data, null, 2));
            } catch (error) {
                log('初始化错误: ' + error.message);
            }
        }

        async function testDataStats() {
            try {
                log('获取数据统计...');
                const response = await fetch('https://localhost:7002/api/DataInit/data-stats');
                const data = await response.json();
                log('数据统计: ' + JSON.stringify(data, null, 2));
            } catch (error) {
                log('数据统计错误: ' + error.message);
            }
        }
    </script>
</body>
</html> 